
//回显数据，填充表格
function setFormValue(obj) {
    // console.log(obj);
    let data = obj.data;
    let status_value = true;
    if (data.status === 2) {
        status_value = false;
    }
    //1和4 填空和排序 正确答案用rightKeyEntry      听力和选择相同3和2
    if(data.typeid==2){//选择
        $('#rightSelects').removeClass('layui-hide');
        $('#rightChooses').removeClass('layui-hide');
        $("#rightpaixu" ).addClass("layui-hide");
        $('#rightEntry').addClass('layui-hide');
        $('#rightorRong').addClass('layui-hide');

        $("input[type=radio][name=rightKey][value="+data.rightKey+"]").attr("checked","checked");
        form.render(); //更新全部

    } else  if(data.typeid==1){//填空rightKeyEntry
        $("#rightEntry").removeClass('layui-hide');
        $("#rightpaixu").addClass("layui-hide");
        $('#rightSelects').addClass('layui-hide');
        $('#rightChooses').addClass('layui-hide');
        $('#rightorRong').addClass('layui-hide');
        $("#rightEntrys").val(data.rightKey);
    }else  if(data.typeid==3){//听力
        $('#rightSelects').removeClass('layui-hide');
        $('#rightChooses').removeClass('layui-hide');
        $('#rightEntry').addClass('layui-hide');
        $('#rightorRong').addClass('layui-hide');
        $('#rightpaixu').addClass('layui-hide');
        $("input[type=radio][name=rightKey][value="+data.rightKey+"]").attr("checked","checked");
        form.render(); //更新全部
    }else  if(data.typeid==4){//排序
        $('#rightEntry').removeClass('layui-hide');
        $('#rightSelects').addClass('layui-hide');
        $('#rightpaixu').addClass('layui-hide');
        $('#rightChooses').addClass('layui-hide');
        $('#rightorRong').addClass('layui-hide');
        $("#rightEntrys").val(data.rightKey);
    }else  if(data.typeid==5){//完形填空
        $('#rightSelects').addClass('layui-hide');
        $('#rightChooses').addClass('layui-hide');
        $('#rightEntry').addClass('layui-hide');
        $('#rightorRong').addClass('layui-hide');
        $('#rightpaixu').addClass('layui-hide');
    }else  if(data.typeid==6){//对错
        // $('#rightSelect').addClass('layui-hide');
        $('#rightorRongs').removeClass('layui-hide');
        $('#rightSelects').addClass('layui-hide');
        $('#rightChooses').addClass('layui-hide');
        $('#rightEntry').addClass('layui-hide');
        $('#rightpaixu').addClass('layui-hide');
        $("input[type=radio][name=rightorRongs][value="+data.rightKey+"]").attr("checked","checked");
        form.render(); //更新全部
    }

//图片
    $('#imageLists').val()
    $('#subjectimg img').remove()
    $('#imageLists').append("[")
    var str="[";
    let arry=[];
    var id=1;

    if(data.imageList!=null&&data.imageList!="") {
        $('#subjectimg').children().remove()
        $(data.imageList).each(function (index, item) {
            id+=1;
            $('#subjectimg').append('<div><div id='+id+'><img src=' + item.imageUrl + '  id=' + item.id + ' name="' + item.name + '" style="width:80px; height:80px; display:block; " /></div><a class=" delete-btn">删除</a></div>');
            str += "{'name':'" + item.name + "','imageUrl':'" + item.imageUrl + "'},";
            // arry.push({'name':item.name,'imageUrl':item.imageUrl})
        });
        str = str.substr(0, str.length - 1);

        if(str!=null&&str!=""){
            str += "]"
        }

    $('#imageLists').val(str)
    }

    $('#recordingList').val()
    //音频
    var strs="[";
    if(data.recoList!=null&&data.recoList!=""){
        $('#subjectrecord').children().remove()
    $(data.recoList).each(function (index, item) {
        $('#subjectrecord').append('<audio controls  id='+item.id+' style=" width: 70px;height:30px;"  > <source  type="audio/ogg" src='+item.recordingUrl+' id="" name=""  /> </audio> &nbsp;');

        strs+="{'name':'"+item.name+"','recordingUrl':'"+item.recordingUrl+"'},";
    });
    strs=strs.substr(0,strs.length-1);
    strs+="]"
    $('#recordingList').val(strs)
    }

    //视频
    var strss="[";
    var videos=[];
    $('#videoLists').val()
    if(data.videoList!=null&&data.videoList!=""){
        $('#subjectvideo').children().remove()
    $(data.videoList).each(function (index, item) {
        $('#subjectvideo').append('<div><div id='+id+'><video controls="controls"  id='+item.id+'  style=" width: 100px;height:100px;" > <source  type="video/mp4" src='+item.videoUrl+' id="" name="" style=\\"width:100px; height:100px; display:block; " /> </video>&nbsp;</div><a class=" delete-btn">删除</a></div>');
        strss+="{'name':'"+item.name+"','videoUrl':'"+item.videoUrl+"'},";
        // videos.push({"name":item.name,"videoUrl":item.videoUrl})
    });
    strss=strss.substr(0,strss.length-1);
    strss+="]"
    $('#videoLists').val(strss)
    }

    form.val("languageEditFilter", {
        "entryName": data.entryName
        , "id": data.id
        , "stem": data.stem
        , "statusv": 1

        ,"type":data.type
        ,"language":data.language
        ,"hskvs":data.hsk
        // ,"rightEntrys":data.rightKey
        ,'chooseA':data.chooses[0]==null?null:data.chooses[0].text
        ,'chooseB':data.chooses[1]==null?null:data.chooses[1].text
        ,'chooseC':data.chooses[2]==null?null:data.chooses[2].text
        ,'chooseD':data.chooses[3]==null?null:data.chooses[3].text




    });
    form.render();
}



//回显数据，填充表格s
function setFormValues(obj) {
    // console.log(obj);
    let data = obj.data;
    let status_value = true;
    if (data.status === 2) {
        status_value = false;
    }
    //1和4 填空和排序 正确答案用rightKeyEntry      听力和选择相同3和2
    if(data.typeid==2){//选择
        $('#rightSelectssa').removeClass('layui-hide');
        $('#rightChoosessa').removeClass('layui-hide');
        $("#rightpaixusa" ).addClass("layui-hide");
        $('#rightEntrysa').addClass('layui-hide');
        $('#rightorRongsa').addClass('layui-hide');

        $("input[type=radio][name=rightKey][value="+data.rightKey+"]").attr("checked","checked");
        form.render(); //更新全部

    } else  if(data.typeid==1){//填空rightKeyEntry
        $("#rightEntrysa").removeClass('layui-hide');
        $("#rightpaixusa").addClass("layui-hide");
        $('#rightSelectssa').addClass('layui-hide');
        $('#rightChoosessa').addClass('layui-hide');
        $('#rightorRongsa').addClass('layui-hide');
        $("#rightEntrysss").html(data.rightKey);
    }else  if(data.typeid==3){//听力
        $('#rightSelectssa').removeClass('layui-hide');
        $('#rightChoosessa').removeClass('layui-hide');
        $('#rightEntrysa').addClass('layui-hide');
        $('#rightorRongsa').addClass('layui-hide');
        $('#rightpaixusa').addClass('layui-hide');
        $("input[type=radio][name=rightKey][value="+data.rightKey+"]").attr("checked","checked");
        form.render(); //更新全部
    }else  if(data.typeid==4){//排序
        $('#rightEntrysa').removeClass('layui-hide');
        $('#rightSelectssa').addClass('layui-hide');
        $('#rightpaixusa').addClass('layui-hide');
        $('#rightChoosessa').addClass('layui-hide');
        $('#rightorRongsa').addClass('layui-hide');
        $("#rightEntrysss").html(data.rightKey);

    }else  if(data.typeid==5){//完形填空
        $('#rightSelectssa').addClass('layui-hide');
        $('#rightChoosessa').addClass('layui-hide');
        $('#rightEntrysa').addClass('layui-hide');
        $('#rightorRongsa').addClass('layui-hide');
        $('#rightpaixusa').addClass('layui-hide');
    }else  if(data.typeid==6){//对错
        // $('#rightSelect').addClass('layui-hide');
        $('#rightorRongsa').removeClass('layui-hide');
        $('#rightSelectssa').addClass('layui-hide');
        $('#rightChoosessa').addClass('layui-hide');
        $('#rightEntrysa').addClass('layui-hide');
        $('#rightpaixusa').addClass('layui-hide');
        $("input[type=radio][name=rightorRongsva][value="+data.rightKey+"]").attr("checked","checked");
        form.render(); //更新全部
    }

//图片
    $('#imageLists').val()
    $('#subjectimgvb img').remove()
    $('#imageLists').append("[")
    let arry=[];
    var id=1;


        $('#subjectimgvb').children().remove()
        $(data.imageList).each(function (index, item) {
            id+=1;
            $('#subjectimgvb').append('<div><div id='+id+'><img src=' + item.imageUrl + '  id=' + item.id + ' name="' + item.name + '" style="width:80px; height:80px; display:block; " /></div><a class=" delete-btn">删除</a></div>');
            // arry.push({'name':item.name,'imageUrl':item.imageUrl})
        });



    $('#recordingList').val()
    //音频
    if(data.recoList!=null&&data.recoList!=""){
        $('#subjectrecordvb').children().remove()
        $(data.recoList).each(function (index, item) {
            $('#subjectrecordvb').append('<audio controls  id='+item.id+' style=" width: 70px;height:30px;"  > <source  type="audio/ogg" src='+item.recordingUrl+' id="" name=""  /> </audio> &nbsp;');

        });
    }

    //视频
    var videos=[];
    $('#videoLists').val()
        $('#subjectvideovb').children().remove()
        $(data.videoList).each(function (index, item) {
            $('#subjectvideovb').append('<div><div id='+id+'><video controls="controls"  id='+item.id+'  style=" width: 100px;height:100px;" > <source  type="video/mp4" src='+item.videoUrl+' id="" name="" style=\\"width:100px; height:100px; display:block; " /> </video>&nbsp;</div><a class=" delete-btn">删除</a></div>');
            // videos.push({"name":item.name,"videoUrl":item.videoUrl})
        });


$("#entryNames").html(data.entryName)
    $("#stems").html(data.stem)

    if(data.type==1){
        $("#stemType").html("填空")
    } if(data.type==2){
        $("#stemType").html("选择")
    } if(data.type==3){
        $("#stemType").html("听力")
    } if(data.type==4){
        $("#stemType").html("排序")
    } if(data.type==5){
        $("#stemType").html("完型填空")
    } if(data.type==6){
        $("#stemType").html("判断")
    }
    form.val("languageEditFilter", {
        // ,"rightEntrys":data.rightKey
        'chooseA':data.chooses[0]==null?null:data.chooses[0].text
        ,'chooseB':data.chooses[1]==null?null:data.chooses[1].text
        ,'chooseC':data.chooses[2]==null?null:data.chooses[2].text
        ,'chooseD':data.chooses[3]==null?null:data.chooses[3].text




    });
    form.render();
}